package utils

import (
	"net"
	"strings"
)

/**
 * @Description: 获取当前计算机的对外Ip地址
 * @return ip  ip地址
 * @return err 错误值
 */
func GetCurrentComputerIp() (ip string, err error) {
	conn, err := net.Dial("udp", "8.8.8.8:80")
	if err != nil {
		return "", err
	}
	defer conn.Close()
	localAddr := conn.LocalAddr().(*net.UDPAddr)
	ip = strings.Split(localAddr.IP.String(), ":")[0]
	return ip, nil
}
